﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Cobit5.Web.Cobit
{
    public partial class GoalProcessDelete : System.Web.UI.Page
    {
        public int goalProcessId;

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                this.goalProcessId = int.Parse(Request.QueryString["id"].ToString());
            }
            catch
            {
                Response.Redirect("GoalProcessList.aspx");
            }

            if (BIZ.Cobit.GoalProcess.ExistGoalProcess(goalProcessId) == 0)
                Response.Redirect("GoalProcessList.aspx");

            FillGoalProcessData(this.goalProcessId);
        }

        protected void FillGoalProcessData(int in_id)
        {
            BIZ.Cobit.GoalProcess myGoalProcess = new BIZ.Cobit.GoalProcess(in_id);
            Label_Id.Text = myGoalProcess.id.ToString();
            Label_DescriptionCHN.Text = myGoalProcess.descriptionCHN;
            Label_Description.Text = myGoalProcess.description;
            Label_RelatedMetricCHN.Text = myGoalProcess.relatedMetricCHN;
            Label_RelatedMetric.Text = myGoalProcess.relatedMetric;
        }
       
        protected void Button_Confirm_Click(object sender, EventArgs e)
        {
            int ok=BIZ.Cobit.GoalProcess.DeleteGoalProcess(goalProcessId);
            switch (ok)
            {
                case 1: Label_Result.Text = "删除成功！"; Button_Confirm.Visible = false; Button_Cancel.Text = "返回"; break;
                default: Label_Result.Text = "删除出错，错误代码：" + ok.ToString() + "，请与系统管理员联系"; break;
            }
        }

        protected void Button_Cancel_Click(object sender, EventArgs e)
        {
            Response.Write("<script language=javascript>history.go(-2);</script>");
        }
    }
}